package com.musiklegal;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class ExpandAdapter extends BaseExpandableListAdapter
{
	List<AnAdapter> groupList;
	Activity act;
	LayoutInflater inflater;
	ExpandAdapter(Activity a, List<AnAdapter> p)
	{
		act = a;
		groupList=p;
		inflater = (LayoutInflater) a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	public Object getChild(int groupPosition, int childPosition) {
		
		return groupList.get(groupPosition).getItem(childPosition);
	}

	public long getChildId(int groupPosition, int childPosition) {
		
		return Long.parseLong(Long.toString(groupPosition)+Long.toString(childPosition));
	}

	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) 
	{
		
		BaseAdapter lv = groupList.get(groupPosition);
		View v =lv.getView(childPosition, convertView, parent);
		
		return v;
	}

	public int getChildrenCount(int groupPosition) {
		
		return groupList.get(groupPosition).getCount();
	}

	public Object getGroup(int groupPosition) {
		
		return groupList.get(groupPosition).data;
	}

	public int getGroupCount() {
		
		return groupList.size();
	}

	public long getGroupId(int groupPosition) {
		
		return groupPosition;
	}
	
	static class ViewHolder
	{
		TextView judul;//,artist;
		//ImageView img;
	}

	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		
		TextView vi = new TextView(act.getApplicationContext());
		vi.setText("Other song");
		return vi;
	}

	public boolean hasStableIds() {
		
		return true;
	}

	public boolean isChildSelectable(int groupPosition, int childPosition) {
		
		return true;
	}
	
	

}
